﻿using Common.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sigma.Admin.Client
{
    public class DataSeed
    {
        public static List<MenuDto> GetMenus()
        {
            return new List<MenuDto>()
            {
                new MenuDto(){Id=1,PId=-1, Icon=1970,TitleName="系统管理",Target="",Sort=1,Level=0 ,IsView=false},
            new MenuDto() { Id =2,PId=1,  TitleName ="用户管理", Target ="UsersView", Sort =0, Level =1, IsView =true},
            new MenuDto() { Id =3,PId=1,  TitleName ="角色管理", Target ="RolesView", Sort =1, Level =1,  IsView = true },
            new MenuDto() { Id =4, PId = 1,  TitleName ="权限管理", Target ="PermissionView", Sort =2, Level =1, IsView = true },
            new MenuDto() { Id =5, PId = 1,  TitleName ="菜单管理", Target ="MenuView", Sort =3, Level =1,  IsView = true },
            new MenuDto() { Id =6,PId=-1, Icon =131, TitleName ="业务管理", Target ="", Sort =1, Level =0,  IsView = true },
            new MenuDto() { Id =7, PId = 6,  TitleName = "任务管理", Target = "TaskView", Sort =0, Level =1, IsView = true },
            new MenuDto() { Id =8, PId = 6,  TitleName = "文件管理", Target = "FileView", Sort =1, Level =1,  IsView = true },
            new MenuDto() { Id =9, PId=-1,Icon =2270, TitleName = "缓存管理", Target = "", Sort =3, Level =0,  IsView = true },
            new MenuDto() { Id =10, PId = 9,  TitleName = "前台缓存", Target = "ForCacheView", Sort =0, Level =1,  IsView = true },
            new MenuDto() { Id =11, PId = 9, TitleName = "后台缓存", Target = "BackCacheView", Sort =1, Level =1, IsView = true },
            new MenuDto() { Id =12, PId = -1,Icon=1582, TitleName = "流式图表", Target = "", Sort =1, Level =0, IsView = false },
            new MenuDto() { Id =13, PId = 12, TitleName = "曲线图", Target = "OxyChartView", Sort =1, Level =1, IsView = true }
            };
        }

        public static List<MenuDto> BuildMenus(int level = 0)
        {
            var list = GetMenus();
            var result = new List<MenuDto>();
            for (; level < 2; level++)
            {
                var thisLevel = list.Where(x => x.Level == level);
                if (level == 0)
                {
                    result.AddRange(thisLevel);
                }
                else
                {
                    foreach (var i in result.Where(x => x.Level == level - 1))
                    {
                        var res = thisLevel.Where(x => x.PId == i.Id);
                        var child = new List<MenuBaseDto>();
                        child.AddRange(res);
                        i.Children= child;
                    }
                }
            }
            return result;
        }


        public static List<UsersDto> GetUsers()
        {
            return new List<UsersDto>()
            {
                //new UsersDto(){ Id = 1, Name ="",Account="",RoleKey=new List<int>(){1}, CreateTime=DateTime.Now()}
            };
        }
    }
}
